import os
import pandas as pd
from feature_utils import *
import sys
import yaml
import json

dfarr = []
for f in os.listdir('out/'):
    dfarr.append(pd.read_csv('out/' + f, names = COLUMNS, header = None))
dfm = pd.concat(dfarr)
bins = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.7, 0.8, 0.9, 1.0]
qa = dfm.quantile(bins, numeric_only=True)
finfos = {}
for fn in FNAMES:
    fbins = []
    for b in bins:
        fv = qa.at[b, fn]
        fbins.append(fv)
    fbins[0] = -sys.maxsize
    fbins[-1] = sys.maxsize
    # print(fn, fbins)
    finfos[fn] = {'buckets': fbins}

print(json.dumps(finfos, indent = 2))
# print(yaml.dump(finfos))
